package com.yuma.tingshu.account.api;

import com.yuma.tingshu.account.service.RechargeInfoService;
import com.yuma.tingshu.common.annotation.YuMaLogin;
import com.yuma.tingshu.common.result.Result;
import com.yuma.tingshu.model.account.RechargeInfo;
import com.yuma.tingshu.vo.account.RechargeInfoVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Tag(name = "充值管理")
@RestController
@RequestMapping("api/account/rechargeInfo")
@SuppressWarnings({"unchecked", "rawtypes"})
public class RechargeInfoApiController {

    @Autowired
    private RechargeInfoService rechargeInfoService;

	/**
	 * 提交充值
	 * @param rechargeInfoVo
	 * @return
	 */
    @YuMaLogin
    @PostMapping("/submitRecharge")
    public Result<Map<String, Object>> submitRecharge(@RequestBody RechargeInfoVo rechargeInfoVo) {
        Map<String, Object> map = this.rechargeInfoService.submitRecharge(rechargeInfoVo);
        return Result.ok(map);
    }

	/**
	 * 根据订单编号查询充值
	 * @param orderNo
	 * @return
	 */
	@YuMaLogin
	@GetMapping("getRechargeInfo/{orderNo}")
	public Result<RechargeInfo> getRechargeInfo(@PathVariable String orderNo) {
		RechargeInfo rechargeInfo = rechargeInfoService.getRechargeInfo(orderNo);
		return Result.ok(rechargeInfo);
	}

}

